import {
  ILogService,
  Inject,
  Injector,
  Plugin,
  registerDependencies,
  touchDependencies,
} from '@univerjs/core';
import { UpdateSalesController } from './controllers/update-sales.controller.js';

export class MyBizPlugin extends Plugin {
  static override pluginName = 'MY_BIZ_PLUGIN';

  constructor(
    @Inject(Injector) protected readonly _injector: Injector,
    @ILogService private readonly _logService: ILogService,
  ) {
    super();

    this._logService.log(`MyBizPlugin: Initializing ${MyBizPlugin.pluginName}`);
  }

  override onStarting(): void {
    // 在 Staring 生命周期注册依赖
    registerDependencies(this._injector, [[UpdateSalesController]]);

    // 如果没有其他模块依赖 UpdateSalesController，需要手动获取它以便触发实例化
    touchDependencies(this._injector, [[UpdateSalesController]]);
  }
}
